<?php

/**
 * @description: kiosk addon config
 * @author sunnyw<iwisunny@gmail.com>
 */
class Kiosk_addon_model extends MY_Model
{

    protected $_table = 'kiosk_addon';
    protected $return_type = 'array';

    function __construct()
    {
        parent::__construct();
    }

    function set_data($kiosk_id, $data)
    {
        $status = false;
        $check_row = $this->get_by(['kiosk_id' => $kiosk_id]);
        if(empty($check_row)) {
            //add row
            $data['kiosk_id'] = $kiosk_id;
            $insert_id = $this->insert($data, true);
            $status = $insert_id > 0;
        }
        else {
            //update row
            $status = $this->update_by(['kiosk_id' => $kiosk_id], $data);
        }

        return $status;
    }

    function get_filled_teamvwr(){
        return $this->db->select('kiosk_id')
            ->get_where($this->_table, ['teamvwr_id !='=>'', 'teamvwr_pwd !='=>''])
            ->result_array();
    }
}